$(function () {

  let math = MathQuill.getInterface(2),
    formula = $("#formula").get(0),
    text = "",
    inter = math.MathField(formula, {
      handlers: {
        edit: () => {
          var formula = inter.latex();
          text = formula ;
        }
      }
    });
  $('input[type="button"]').click(() => {
    var formula = $('<p><span class="formula"></span></p>');
    formula.find(".formula").html(text);
    math.StaticMath(formula.find(".formula").get(0));
    $(".math").append(formula);
  });
});
